<template>
	<wrapPopup v-if="isShow" @click.stop="onDismiss">
		<view class="wrap-open-redbag" @click.stop.prevent>
			<image class="img" :src="$staticImagePath('article/open_redBag.png')" @click.stop="onOpen" />
		</view>
	</wrapPopup>
</template>

<script>
	import {ArticleGetPacket} from "@/API/article.js";
	import wrapPopup from "@/components/popup/popup.vue";
	export default {
		components: {
			wrapPopup
		},
		props: {
			/**
			 * 文章ID
			 */
			articleID: {
				type: String,
				default: "",
			},
			/**
			 * 是否弹起红包
			 */
			isShow: {
				type: Boolean,
				default: false,
			},
		},
		methods: {
			/**
			 * 弹窗
			 */
			onDismiss() {
				this.$emit("update:isShow", false);
			},
			/**
			 * 打开红包
			 */
			onOpen() {
				ArticleGetPacket(this.articleID).then(res => {
					this.$emit("onReceiveSuccess")
					this.onDismiss();
					let obj = {
						money: res.data.money,
						type: res.data.type,
						shop_id: res.data.shop_id,
						article_id: this.articleID,
					};
					this.$jump.to(`/pages/home/article/receiveResult?obj=${JSON.stringify(obj)}`);
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wrap-open-redbag {
		width: 750rpx;
		height: 750rpx;
		overflow: hidden;
		
		.img {
			width: 750rpx;
			height: 750rpx;
			overflow: hidden;
		}
	}
</style>